"use strict";

const Service = require("egg").Service;

class MemberService extends Service {
  async findByMemName(memname) {
    const { app } = this;
    const res = await app.model.Member.findOne({
      where: {
        memname
      }
    });
    return res;
  }
  async addMember(memname, memlevel, discount, lowpoint, highpoint, desc) {
    const { app, ctx } = this;
    // 当前用户名
    const creator = ctx.tokenUser.username;
    const res = await app.model.Member.create({
      memname,
      memlevel,
      discount,
      lowpoint,
      highpoint,
      desc,
      creator
    });
    return res;
  }
}

module.exports = MemberService;
